import { config, request } from 'utils'

const { api } = config
const {
  spaceResourcesQueryUrl,
  queryHistoryImageUrl,
  mapSpecialQueryUrl
} = api

// POST，请求方式
export async function spaceResourcesQuery(params) {
  return request(spaceResourcesQueryUrl, {
    method: 'POST',
    data: params,
  });
}


export async function queryMap(param){
  const { type, ...params } = param;
  const queryStr = Object.keys(params)
    .map(key => params[key] && `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`)
    .join('&');
  return request(`${type}/query?f=json&`+queryStr, {
    method: 'GET',
    data: params,
  });
}

export async function queryHistoryImage(params) {
  return request(queryHistoryImageUrl, {
    method: 'POST',
    data: params,
  });
}


export async function mapSpecialQuery(params) {
  return request(mapSpecialQueryUrl, {
    method: 'POST',
    data: params,
  });
}
